{extend name="Public:content"}
{block name="content"}
<form class="form-horizontal m-t" id="addCateFrom"  method="post" action='{:url("$classuri/add")}'>
    <div class="form-group">
        <label class="col-sm-2 control-label">上级分类：</label>
        <div class="col-sm-8">
            <select name='pid' class='form-control m-b'>
                <!--{foreach $cates as $cate}-->
                <!--{eq name='cate.id' value='$vo.pid|default=0'}-->
                <option selected value='{$cate.id}'>{$cate.spl}{$cate.cate}</option>
                <!--{else}-->
                <option value='{$cate.id}'>{$cate.spl}{$cate.cate}</option>
                <!--{/eq}-->
                <!--{/foreach}-->
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">分类名称：</label>
        <div class="col-sm-8">
            <input type="text" name="cate" rangelength="[2,200]" required="true" placeholder="请输入分类名称" title="请输入分类名称" class="form-control">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">排序：</label>
        <div class="col-sm-8">
            <input type="text" name="sort" required="true" number="true" placeholder="请输入数字" title="请输入数字" class="form-control">
        </div>
    </div>
    <div class="hr-line-dashed"></div>
    <div class="form-group">
        <div class="col-sm-12 text-center">
            <button class="btn btn-primary" type="submit">保存数据</button>
            <button class="btn btn-primary btn-danger" type='button' data-confirm="确定要取消编辑吗？" onclick="$.Oa.confirm(this)">取消编辑</button>
        </div>
    </div>
</form>
{/block}
{block name="script"}
<script type="text/javascript">
    //表单提交
    $('#addCateFrom').validate({
        submitHandler: function(form) {
            $.Oa.doHform('#addCateFrom',false,false,function(data){
                parent.layer.msg(data.msg);
                var iframe ='{$iframe}';
                var n = parent.$("iframe[name='"+iframe+"']").index();
                parent[n].$('#category_table').bootstrapTable('refresh');
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            })
        }
    })
</script>
{/block}
